#include <iostream>
#include <string>
#include<memory>

using namespace std;

class VideoSite
{
public:
    virtual void freeMovie() = 0;
    virtual void vipMovie() = 0;
    virtual void ticketMovie() = 0;
};
class FixBugVideoSite:public VideoSite
{
    // 不同的用户的访问权限可能不够，所以下面三个函数有些对象不能调用
    void freeMovie()
    {
        cout << "观看免费电影" << endl;
    }
    void vipMovie()
    {
        cout << "观看vip电影" << endl;
    }
    void ticketMovie()
    {
        cout << "观看电影券电影" << endl;
    }
};

// 代理类，用于代理FixBugVideoSite
class FreeVideoSiteProxy:public VideoSite
{
public:
    FreeVideoSiteProxy()
    {
        pVideo = new FixBugVideoSite();
    }
    ~FreeVideoSiteProxy()
    {
        if(pVideo!=nullptr)
        {
            delete pVideo;
        }
        pVideo = nullptr;
    }
    void freeMovie()
    {
        pVideo->freeMovie();
    }
    void vipMovie()
    {
        cout << "您目前只是普通用户，需要升级成vip才能观看vip电影" << endl;
    }
    void ticketMovie()
    {
        cout << "您目前只是普通用户，需要购买电影券才能观看电影" << endl;
    }

private:
    VideoSite *pVideo;
};
class VipVideoSiteProxy : public VideoSite
{
public:
    VipVideoSiteProxy()
    {
        pVideo = new FixBugVideoSite();
    }
    ~VipVideoSiteProxy()
    {
        if (pVideo != nullptr)
        {
            delete pVideo;
        }
        pVideo = nullptr;
    }
    void freeMovie()
    {
        pVideo->freeMovie();
    }
    void vipMovie()
    {
        pVideo->vipMovie();
    }
    void ticketMovie()
    {
        cout << "您目前只是普通用户，需要购买电影券才能观看电影" << endl;
    }

private:
    VideoSite *pVideo;
};
int main()
{
    // unique_ptr<VideoSite> p1(new FreeVideoSiteProxy());
    unique_ptr<VideoSite> p1(new VipVideoSiteProxy());
    p1->freeMovie();
    p1->vipMovie();
    p1->ticketMovie();

    return 0;
}